﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using Microsoft.Phone.Controls;
using QuanLyBus.Model;

namespace QuanLyBus
{
    public partial class xem_lo_trinh : PhoneApplicationPage
    {
        
        //string[] lo_trinh = {"Trần Hưng đạo","Trần Hưng Đạo B","Châu Văn Liêm" };
        QL_TuyenDataContext db = new QL_TuyenDataContext(App.constr);
        string a,b;        
        public xem_lo_trinh()
        {
            InitializeComponent();
            txb_tso.Text = "Tuyến số: "+App.id.ToString();
            luot_di();
            luot_ve();
            //MessageBox.Show(a);
            //list_tuyen_di.ItemsSource = lo_trinh_di;
            //list_tuyen_ve.ItemsSource = lo_trinh_ve;
        }
        private void luot_di()
        {
            var lo_trinh_di = (from c in db.ds_trams
                               join o in db.tram_thuoc_tuyens
                                on c.id_tram equals o.id_tram
                               where o.id_tuyen == App.id
                               where o.tram_ve == 1
                               select c.duong).Distinct();
            foreach (string p in lo_trinh_di)
            {
                
                    a = a + p +  "\n";               
               

              
            }
            txb_luot_di.Text = a;
        }
        private void luot_ve()
        {
            var lo_trinh_ve = (from c in db.ds_trams
                               join o in db.tram_thuoc_tuyens
                                on c.id_tram equals o.id_tram
                               where o.id_tuyen == App.id
                               where o.tram_ve == 0
                               select c.duong).Distinct();
            foreach (string p in lo_trinh_ve)
            {
               
                    b = b + p + "\n";
               
            }
            txb_luot_ve.Text = b;
        }

        private void btn_chi_tiet_Click(object sender, EventArgs e)
        {
            this.NavigationService.Navigate(new Uri("/thong_tin_chi_tiet_tuyen.xaml",UriKind.Relative));
        }

        

        private void btn_trang_chinh_Click(object sender, EventArgs e)
        {
            this.NavigationService.Navigate(new Uri("/MainPage.xaml", UriKind.Relative));
        }
    }
}